package com.carlinfo.userscenter.stu.pojo;

import java.util.Date;
import java.util.Map;
import java.util.TreeMap;
import java.io.Serializable;
import java.util.Date;

/**
 * 问题
 * 属性:id,名字,得分,回答总人数,创建时间,结束时间
 * @author wll
 */
public class Question implements Serializable
{
	private int id;
	private String name;
	private int score;
	private int people;
	private Date createTime;
	private Date endTime;
	private Date pubTime;
	private String context;
	private byte status;
	
	/* 定义状态的字符串 */
	private String statusStr;
	private Map<String, ADynastyEnum> statusMap;
	public int getId()
	{
		return id;
	}
	public void setId(int id)
	{
		this.id = id;
	}
	public String getName()
	{
		return name;
	}
	public void setName(String name)
	{
		this.name = name;
	}
	public Date getCreateTime()
	{
		return createTime;
	}
	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}
	public Date getEndTime()
	{
		return endTime;
	}
	public void setEndTime(Date endTime)
	{
		this.endTime = endTime;
	}
	public String toString()
	{
		String name = this.name;
		if(getName().length()>20) {
			name = getName().substring(0,20)+"...";
		}
		String result = getId() +"\t" + name+"\t"+getScore() + "\t"+getPeople()
		+"\t"+getCreateTime().toLocaleString()+"\t"+getEndTime().toLocaleString();
		return result;
		
	}
	public int getScore()
	{
		return score;
	}
	public void setScore(int score)
	{
		this.score = score;
	}
	public int getPeople()
	{
		return people;
	}
	public void setPeople(int people)
	{
		this.people = people;
	}
	public Date getPubTime()
	{
		return pubTime;
	}
	public void setPubTime(Date pubTime)
	{
		this.pubTime = pubTime;
	}
	public String getContext()
	{
		return context;
	}
	public void setContext(String context)
	{
		this.context = context;
	}
	public byte getStatus()
	{
		return status;
	}
	public void setStatus(byte status)
	{
		this.status = status;
	}
	
	public String getStatusStr()
	{
		ADynastyEnum[] values = ADynastyEnum.values();
		for (ADynastyEnum enumTemp : values)
		{
			if(this.status==enumTemp.getValue() && enumTemp.toString().startsWith("STATUS_"))
			{
				this.statusStr = enumTemp.getInfo();
			}
		}
		return statusStr;
	}
	
	public Map<String, ADynastyEnum> getStatusMap()
	{
		this.statusMap= new TreeMap<String, ADynastyEnum>();
		ADynastyEnum[] values = ADynastyEnum.values();
		for (ADynastyEnum enumTemp : values)
		{
			if(enumTemp.toString().startsWith("STATUS_"))
			{
				this.statusMap.put(enumTemp.getValue()+"", enumTemp);
			}
		}
		return statusMap;
	}
}

